package org.mics.core.config;

import org.mics.core.interceptor.RLockInterceptor;
import org.mics.core.interceptor.RepeatSubmitInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@ConditionalOnProperty(prefix = "cyy.componet.cache",name="type",havingValue = "redis" )
public class RepeatSubmitMvcConfig  implements WebMvcConfigurer{
	 @Autowired
	 private RepeatSubmitInterceptor repeatSubmitInterceptor;
	 @Autowired
	 private RLockInterceptor rLockInterceptor;
	 	 

    /**
     * 自定义拦截规则
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    	
        registry.addInterceptor(repeatSubmitInterceptor)
        .addPathPatterns("/**")
        .excludePathPatterns("/upload/**","/**/*.css", "/**/*.js", "/**/*.png", "/**/*.jpg", "/**/*.jpeg","/**/*.html");//排除upload
        registry.addInterceptor(rLockInterceptor)
        .addPathPatterns("/**")
        .excludePathPatterns("/upload/**","/**/*.css", "/**/*.js", "/**/*.png", "/**/*.jpg", "/**/*.jpeg","/**/*.html");//排除upload
       
    }
	
}
